package org.yu.api.register.data;

import net.minecraft.data.DataGenerator;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.yu.api.register.BlockHolder;


import javax.annotation.Nonnull;
import java.util.Map;
import java.util.function.BiConsumer;

public class LazyBlockStateProvider extends BlockStateProvider {
    private final Map<BlockHolder<?>, BiConsumer<BlockStateProvider, BlockHolder<?>>> iBlockStateMap;
    private final String modid;

    public LazyBlockStateProvider(DataGenerator generator, String modid, ExistingFileHelper fileHelper, Map<BlockHolder<?>, BiConsumer<BlockStateProvider, BlockHolder<?>>> iBlockStateMap) {
        super(generator, modid, fileHelper);
        this.iBlockStateMap = iBlockStateMap;
        this.modid = modid;
    }

    @Override
    protected void registerStatesAndModels() {
        iBlockStateMap.forEach(((blockHolder, iBlockState) -> iBlockState.accept(this, blockHolder)));
    }

    @Nonnull
    @Override
    public String getName() {
        return "LazyBlockStateProvider For " + modid;
    }
}
